﻿Public Class XMLEditor
    Private Sub XMLEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.linenumbers = True Then
            FastColoredTextBox1.ShowLineNumbers = True
        Else
            FastColoredTextBox1.ShowLineNumbers = False
        End If
        Dim path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
        Dim reader As New System.IO.StreamReader(path + "gadget.xml", System.Text.Encoding.UTF8)
        FastColoredTextBox1.Text = reader.ReadToEnd()
        reader.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            Dim path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
            Dim writer As New System.IO.StreamWriter(path + "gadget.xml", False, System.Text.Encoding.UTF8)
            writer.Write(FastColoredTextBox1.Text)
            writer.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Me.Close()
    End Sub

End Class